<?php
require './configs/config.php';


function mvc_autoload($classname)
{
    if (file_exists("./models/{$classname}.class.php")){
        require "./models/{$classname}.class.php";
    } elseif (file_exists("./controllers/{$classname}.php")){
        require "./controllers/{$classname}.php";
    } else {
        echo '<h1>404 NOT FOUND</h1>';
        exit;
    }
}
require './libs/Smarty.class.php';
// $smarty = new Smarty();
//与$smarty对象的autoload冲突,我们自己定义一个新的autoload
spl_autoload_register('mvc_autoload');
// var_dump($smarty);

//获取控制器
$c = (!empty($_GET['c']))?$_GET['c']:'Index';
//获得方法
$a = (!empty($_GET['a']))?$_GET['a']:'index';

$classname = $c .'Controller';

$controller = new $classname;

$controller->$a();

